<template>
  <div>
    <Row class="header" type="flex" justify="center">
      <Col span="24">
        <Icon class="icon" type="md-pie"/>
        <span class="title">折线图</span>
      </Col>
    </Row>
    <br>
    <div id="TypesLine" :style="{ width: width + 'px', height: height + 'px'}"></div>
  </div>
</template>

<script>
import echarts from 'echarts'
// import mockData from './mockData'

export default {
  name: 'TypesCompanyLineEchart',
  data () {
    return {
      chartData: []
    }
  },
  props: {
    width: {
      type: Number,
      default: () => {
        return 300
      }
    },
    height: {
      type: Number,
      default: () => {
        return 200
      }
    }
  },
  mounted () {
    this.chart()
  },
  methods: {
    chart () {
      let option = {
        legend: {
          textStyle: {
            fontSize: 18, // 字体大小
            color: '#ffffff'// 字体颜色
          },
          data: ['aa'],
          left: 10
        },
        grid: {
          right: '1px',
          left: '30px',
          bottom: '10%',
          containLabel: true
        },
        tooltip: {
          trigger: 'axis'
        },
        xAxis: {
          axisLabel: {
            show: true,
            textStyle: {
              color: '#ffffff'
            }
          },
          type: 'category',
          boundaryGap: false,
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
          axisLabel: {
            textStyle: {
              color: '#ffffff'
            }
          },
          type: 'value'
        },
        series: [{
          name: 'aa',
          color: ['#E58DC2'],
          data: [820, 932, 901, 934, 1290, 1330, 1320],
          type: 'line',
          areaStyle: {}
        }]
      }

      this.chartData.forEach(item => {
        option.dataset.source.push(item)
      })
      let myChart = echarts.init(document.getElementById('TypesLine'))
      myChart.setOption(option)
    }
  }
}
</script>

<style scoped>
  .header {
    height: 10px;
    margin-top: 10px;
    margin-left: 10px;
  }
  .icon {
    color: #d7f5ff;
    font-size: 28px;
    font-weight: 600;
    margin-right: 5px;
  }
  .title {
    color: #d7f5ff;
    font-size: 16px;
    font-weight: 600;
    line-height: 30px;
  }
</style>
